#include <WinTen.h>
#include <Windows.h>
#include <ClipApi.h>

#include <CommDlg.h>

CLIPPER cGetFile()
{
   OPENFILENAME ofn;
   char szDirName[ 256 ], szFile[ 256 ], szFileTitle[ 256 ], szFilter[ 256 ];
   char szTitle[ 256 ];
   BYTE b = 0;

   strcpy( szDirName, "C:\\" );
   strcpy( szFilter, _parc( 1 ) );
   strcat( szFilter, "|" );
   strcat( szFilter, _parc( 1 ) );
   strcat( szFilter, "|" );

   strcpy( szFileTitle, _parc( 1 ) );
   strcpy( szTitle, _parc( 2 ) );
   _xunlock();

   while( * ( szFilter + b ) )
   {
      if( * ( szFilter + b ) == '|' )
         * ( szFilter + b ) = 0;
      b++;
   }

   _bset( ( char * ) &ofn, 0, sizeof( OPENFILENAME ) );
   szFile[ 0 ] = 0;

   ofn.lStructSize     = sizeof( OPENFILENAME );
   ofn.hwndOwner       = GetActiveWindow();
   ofn.lpstrFilter     = szFilter;
   ofn.nFilterIndex    = 1;
   ofn.lpstrFile       = szFile;
   ofn.nMaxFile        = sizeof( szFile );
   ofn.lpstrFileTitle  = szFileTitle;
   ofn.nMaxFileTitle   = sizeof( szFileTitle );
   ofn.lpstrInitialDir = szDirName;
   ofn.lpstrTitle      = szTitle;
   ofn.Flags           = OFN_SHOWHELP | OFN_PATHMUSTEXIST;

   GetOpenFileName( &ofn );

   _retc( szFile );
}
